package com.power200.android.bean;

/**
 * Created by liuming on 10/11/15.
 */
public class BackLog {

    private int id;
    private int priority;
    private String name;
    private String brief;
    private String description;
    private int status;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getPriority() {
        return priority;
    }

    public void setPriority(int priority) {
        this.priority = priority;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getBrief() {
        return brief;
    }

    public void setBrief(String brief) {
        this.brief = brief;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String toFileString() {
        return "i"+id+"_p"+priority+"_n"+name+"_b"+brief+"_d"+description+"_s"+status;
    }

    // 封装下
    public static BackLog parseToFileString(String objectString) {
        BackLog backLog = new BackLog();
        String[] objArryas = objectString.split("_");
        for (String obj: objArryas) {
            if (obj.startsWith("i")) {
                backLog.setId(Integer.parseInt(obj.substring(1)));
            } else if (obj.startsWith("p")){
                backLog.setPriority(Integer.parseInt(obj.substring(1)));
            } else if (obj.startsWith("n")) {
                backLog.setName(obj.substring(1));
            } else if(obj.startsWith("d")) {
                backLog.setDescription(obj.substring(1));
            } else if (obj.startsWith("b")) {
                backLog.setBrief(obj.substring(1));
            } else if (obj.startsWith("s")) {
                backLog.setStatus(Integer.parseInt(obj.substring(1)));
            }
        }
        return backLog;
    }
}
